//优惠券相关操作
import request,{Method} from '@/libs/api.js'

// 获取商城管理端的满减活动分页数据
export function getManagerCouponList (params) {
    return request({
      url: '/coupon/coupon/getManagerCouponList',
      method: Method.POST,
      data: params
    });
}

// 获取商城管理端的优惠券分页数据
export function getManagerCouponPage (params) {
    return request({
      url: '/coupon/coupon/getManagerCouponPage',
      method: Method.POST,
      data: params
    });
}

// 添加平台优惠券(平台券)
export function AddPlatformCoupon (params) {
    return request({
      url: '/coupon/coupon/AddPlatformCoupon',
      method: Method.POST,
      data: params
    });
}

// 根据ID获取平台券的详情
export function getPlatformCouponDetail (id) {
  return request({
    url: `/coupon/coupon/getPlatformCouponDetail/${id}`,
    method: Method.GET,
  });
}

// 编辑平台券的内容
export function editPlatformCoupon (params) {
    return request({
      url: '/coupon/coupon/editPlatformCoupon',
      method: Method.PUT,
      data: params
    });
}

// 关闭当前优惠券活动
export function closeCoupon (id) {
    return request({
      url: `/coupon/coupon/closeCoupon/${id}`,
      method: Method.PUT,
    });
}

// 开启优惠券活动
export function openCoupon (params) {
    return request({
      url: '/coupon/coupon/openCoupon',
      method: Method.PUT,
      data: params
    });
}

// 删除优惠券
export function deleteCoupon (id) {
  return request({
    url: `/coupon/coupon/deleteCoupon/${id}`,
    method: Method.DELETE,
  });
}

// 添加券活动
export function addCouponActivity (params) {
    return request({
      url: '/coupon/couponactivity/addCouponActivity',
      method: Method.POST,
      data: params
    });
}

// 获取官方管理后台的券活动的分页数据
export function getManagerCouponActivityPage (params) {
    return request({
      url: '/coupon/couponactivity/getManagerCouponActivityPage',
      method: Method.POST,
      data: params
    });
}

// 获取官方管理端的去昂活动的详情
export function getManagerCouponActivityDetail (id) {
  return request({
    url: `/coupon/couponactivity/getManagerCouponActivityDetail/${id}`,
    method: Method.GET,
  });
}

// 关闭券活动
export function closeCouponActivity (id) {
  return request({
    url: `/coupon/couponactivity/closeCouponActivity/${id}`,
    method: Method.PUT,
  });
}